package miku.firstgame.net.pack
{
	import miku.firstgame.constrants.ProtocalConstants;
	import miku.firstgame.model.gold.UserOrderVo;
	import miku.firstgame.model.gold.card.Card;
	import miku.firstgame.model.gold.interfaces.ICard;
	import miku.firstgame.net.ByteArrayEx;

	public class GoldGameStartResponsePack extends AbstractReponsePack
	{
		/**
		 * GoldUserType
		 * */
		public var heroType:int;

		public var turn:int;

		public var cards:Vector.<ICard>;

		public var orders:Vector.<UserOrderVo>;

		public function GoldGameStartResponsePack(data:ByteArrayEx)
		{
			super(data);
			cards = new Vector.<ICard>;
			orders = new Vector.<UserOrderVo>;
		}

		override public function decode():void
		{
			//前两位是tag,后两位是状态 0x0001是加密 ,0x0002是其他值
			super.decode();
			data.position = 4;
			heroType = data.readByte();

			var orderCount:int = data.readInt();
			for (var j:int = 0; j < orderCount; j++)
			{
				var o:UserOrderVo = new UserOrderVo();
				o.id = data.readUnsignedInt();
				o.order = data.readShort();
				orders.push(o);
			}

			turn = data.readUnsignedInt();

			var count:int = data.readUnsignedInt();
			for (var i:int = 0; i < count; i++)
			{
				var card:Card = Card.parseCard(data);
				cards.push(card);
			}

		}

		override public function get tag():int
		{
			return ProtocalConstants.GOLD_GAME_START;
		}
	}
}
